<template>
	<van-nav-bar title="推广任务量" />
	
	<van-cell-group inset style="margin-top: 0.625rem;margin-bottom: 0.625rem;">
		<van-field label="保证金" v-model="price" placeholder="请输入保证金" required/>
		<van-field label="计算口径" required>
			<template #input>
				<van-radio-group v-model="type" direction="horizontal">
					<van-radio name="1">发货</van-radio>
					<van-radio name="2">回款</van-radio>
					<van-radio name="3">纯销</van-radio>
				</van-radio-group>
			</template>
		</van-field>
	</van-cell-group>
	
	<van-cell-group inset v-for="(item,index) in 3" :key="index" style="margin-top: 0.625rem;margin-bottom: 0.625rem;">
		<van-cell title="区域" value="四川省-成都市" />
		<van-cell title="品规" value="头孢他定(10g/片)" />
		<van-field label="总销量" placeholder="请设置总销量" @click="showCenter = true" required />
	</van-cell-group>

	<van-action-bar>
		<van-action-bar-icon icon="arrow-left" text="上一步" />
		<van-action-bar-icon icon="gold-coin-o" text="9000" />
		<van-action-bar-button color="#00bffe" type="danger" text="下一步" @click="waychoice = true" />
	</van-action-bar>

	<task-item :showCenter="showCenter" @update:task="updateTask" :tasktype="'pop'"></task-item>

	<van-action-sheet cancel-text="取消" @cancel="waychoice=false" description="任务量" :show="waychoice"
		:actions="menuActions" @select="onSelect" close-on-click-action />

</template>

<script setup lang="ts">
	import { showToast } from 'vant'
	import { ref } from 'vue'
	import { useRouter } from 'vue-router'
	const router = useRouter()
	const showCenter = ref(false);
	const updateTask = (tasks : any) => {
		showCenter.value = false;
	}
	const price = ref(0)
	const type = ref("")
	const waychoice = ref(false)
	const menuActions = ref([{
		name: '开发任务'
	},
	{
		name: '无', child: [{ name: '活动任务' }, { name: '无', child: [{name: '配送商业&联系人',child:[]}] }]
	}
	]);
	// 菜单项选择后的处理函数
	const onSelect = (action : any) => {
		// 根据选择的项修改菜单内容
		if ('开发任务' == action.name) {
			router.push('/expandtasks')
		} else if ('活动任务' == action.name) {
			router.push('/activitytasks')
		}else if ('配送商业&联系人' == action.name) {
		 	router.push('/businessperson')
		}else {
			menuActions.value = action.child;
		}
	};
</script>

<style scoped>
</style>